import Vuex from 'vuex';
import Vue from 'vue';
import * as userApi from '../api/user';
import department from '../pages/departments/store';

Vue.use(Vuex);

export default new Vuex.Store({
    state: {
        userInfo: {},
    },
    mutations: {
        SET_USER_INFO (state, newValue) {
            state.userInfo = newValue;
        },
    },
    actions: {
        async updateUserInfo (context) {
            const res = await userApi.getProfile();
            context.commit('SET_USER_INFO', res.data.data);
        },
    },
    modules: {
        department,
    },
});
